package com.coder520.sync_learning.demo;

import java.util.concurrent.TimeUnit;

public class ThreadInterruptedExit {
    public static void main(String[] args) throws InterruptedException {
        Thread t1=new Thread(){
            @Override
            public void run() {
                System.out.println("我将要开始工作");
                while (!isInterrupted()){
                    System.out.println("我正在工作");
                }
                System.out.println("我结束工作了");
            }
        };

        t1.start();;
        TimeUnit.MINUTES.sleep(1);
        System.out.println("线程将要打断");

        t1.interrupt();

    }

}
